#include<bits/stdc++.h>
using namespace std;
int a[200010],cl[200010],n,ans = 0;
void check(){
    int sum = 0;
    for(int i = 1;i <= n;i++)
        for(int j = i - 1;j > 0;j--)
            if(cl[j] == cl[i] && a[i] == a[j]){
                sum += a[i];
                break;
            }
    ans = max(sum,ans);

}
void dfs(int t){
    if(t > n){
        check();
        return ;
    }
    cl[t] = 0;
    dfs(t + 1);
    cl[t] = 1;
    dfs(t + 1);
}
int main(){
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    int t;
    cin >> t;
    while(t--){
        ans = 0;
        cin >> n;
        for(int i = 1;i <= n;i++) cin >> a[i];
        dfs(1);
        cout << ans << endl;
    }
    fclose(stdin);
    fclose(stdout);
    return 0;
}
